Skip to content

fix(patch): cherry-pick 58df1c6 to release/v0.31.0-preview.0-pr-20374 to patch version v0.31.0-preview.0 and create version 0.31.0-preview.1#20568

Merged
chrstnb merged 1 commit into
release/v0.31.0-preview.0-pr-20374from
hotfix/v0.31.0-preview.0/0.31.0-preview.1/preview/cherry-pick-58df1c6/pr-20374
Feb 27, 2026
Merged

fix(patch): cherry-pick 58df1c6 to release/v0.31.0-preview.0-pr-20374 to patch version v0.31.0-preview.0 and create version 0.31.0-preview.1#20568
chrstnb merged 1 commit into
release/v0.31.0-preview.0-pr-20374from
hotfix/v0.31.0-preview.0/0.31.0-preview.1/preview/cherry-pick-58df1c6/pr-20374

Conversation

@gemini-cli-robot

Copy link
Copy Markdown
Collaborator

This PR automatically cherry-picks commit 58df1c6 to patch version v0.31.0-preview.0 in the preview release to create version 0.31.0-preview.1.

@gemini-cli-robot gemini-cli-robot requested a review from a team as a code owner February 27, 2026 16:10
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request, an automated cherry-pick, enhances the Model Context Protocol (MCP) client's environment variable handling. It introduces the capability to incorporate and resolve environment variables specified within extensions' settings, ensuring that these variables are correctly passed to and utilized by MCP servers. This change improves the flexibility and integration of extensions with the core system.

Highlights

  • Extension Environment Variable Integration: Implemented logic to include environment variables defined in extensions' resolved settings when creating MCP server transports.
  • Environment Variable Resolution Enhancement: Updated the environment variable expansion mechanism to correctly resolve variables from both process environment and extension settings.
  • New Test Cases: Added comprehensive unit tests to validate the correct inclusion and resolution of extension-defined environment variables.
Changelog
  • packages/core/src/tools/mcp-client.test.ts
    • Added a test to ensure extension settings with defined values are included in the environment.
    • Added a test to verify that environment variables in mcpServerConfig.env are resolved using extension settings.
  • packages/core/src/tools/mcp-client.ts
    • Imported GeminiCLIExtension type.
    • Modified createTransportRequestInit to incorporate extension environment variables and pass sanitization configuration.
    • Updated createTransportWithOAuth, retryWithOAuth, connectToMcpServer, and createTransport to accept and utilize sanitizationConfig.
    • Enhanced createTransport to merge extension environment variables into the final environment for command-based transports.
    • Introduced a new helper function getExtensionEnvironment to extract environment variables from extension settings.
Activity
  • This pull request is an automated cherry-pick of a specific commit to patch a preview release, indicating no manual review activity or comments at this stage.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds functionality to make extension settings available as environment variables for MCP server processes, including for variable expansion in server configurations. The changes are generally well-implemented and include corresponding tests. However, a critical security vulnerability was identified where extension-provided environment variables could bypass the sanitization mechanism, potentially leaking sensitive information, which violates the rule regarding sanitizing environments for variable expansion in stdio-based MCP server configurations. A specific comment and code suggestion have been provided to address this issue.

Comment on lines 2009 to 2013
const finalEnv: Record<string, string> = {
[GEMINI_CLI_IDENTIFICATION_ENV_VAR]:
GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE,
...extensionEnv,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-critical critical

This initialization of finalEnv introduces a security vulnerability. By spreading extensionEnv before applying the sanitized environment, any environment variables from the extension that are supposed to be redacted by sanitizeEnvironment will persist in finalEnv. This bypasses the environment sanitization for extension-provided variables.

The sanitizedEnv already contains the correctly filtered and sanitized variables from both process.env and extensionEnv. Therefore, finalEnv should be initialized without spreading extensionEnv first.

    const finalEnv: Record<string, string> = {
      [GEMINI_CLI_IDENTIFICATION_ENV_VAR]:
        GEMINI_CLI_IDENTIFICATION_ENV_VAR_VALUE,
    };
References
  1. Sanitize the environment used for variable expansion in stdio-based MCP server configurations to prevent extensions from bypassing environment variable redaction.

@github-actions

Copy link
Copy Markdown

Size Change: +966 B (0%)

Total Size: 25.7 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 25.2 MB +966 B (0%)
./bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js 221 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js 227 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js 11.5 kB 0 B
./bundle/node_modules/@google/gemini-cli-devtools/dist/src/types.js 132 B 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B
./bundle/sandbox-macos-strict-open.sb 4.82 kB 0 B
./bundle/sandbox-macos-strict-proxied.sb 5.02 kB 0 B

compressed-size-action

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 27, 2026
@chrstnb chrstnb merged commit b153301 into release/v0.31.0-preview.0-pr-20374 Feb 27, 2026
28 checks passed
@chrstnb chrstnb deleted the hotfix/v0.31.0-preview.0/0.31.0-preview.1/preview/cherry-pick-58df1c6/pr-20374 branch February 27, 2026 18:03
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m A medium sized PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants